package cn.anjubao.cp.api.entity;

import cn.anjubao.cp.api.dto.CarDetailData;
import lombok.Data;
import lombok.experimental.Accessors;

import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;

@Data
@Accessors(chain = true)
public class ParkingImage {
    private String id;

    private Long parkingRecordId;

    private Integer imageType;

    private String captureImage;

    private Date captureTime;

    private Date gmtCreate;

    /**
     * 抓拍时间升序排序
     * @param data
     */
    public static void sortByCaptureTimeAsc(List<CarDetailData> data){
        Collections.sort(data, new Comparator<CarDetailData>() {
            @Override public int compare(CarDetailData  o1,CarDetailData o2) {
                if (o1.getCaptureTime().getTime() > o2.getCaptureTime().getTime()) {
                    return 1;
                } else if (o1.getCaptureTime().getTime() <  o2.getCaptureTime().getTime()) {
                    return -1;
                } else {
                    return 0;
                }
            }
        });
    }
}